import { getCurrentInstance } from '@tarojs/taro';
import { View } from '@tarojs/components';
import "taro-ui/dist/style/components/button.scss"; // 按需引入
import { useState, useEffect } from 'react';
import Return from '@/components/Return';
import Header from '@/components/header';
import ThemeDtl from '@/components/Themedtl';
import { getThemedayDetail } from '@/api/application/thematicday';
import css from './index.module.less';

export default function ThemeDayDtl() {
  const [daysDtl, setDaysDtl] = useState({ title: '', contributorName: '', organizationName: '', checkTime: '', browsingAmount: 0, content: '', source: '', reviewerName: '', imgUrl: '' });
  const router = getCurrentInstance().router.params;
  const daysId = router.id;

  useEffect(() => {
    getThemedayDetail(daysId).then((value) => {
      if (value.code === 200) {
        const data = {
          title: value.data.title,
          contributorName: value.data.branchSecretaryName,
          organizationName: value.data.organizationName,
          checkTime: value.data.releaseTime,
          browsingAmount: value.data.viewsNumber,
          content: value.data.learningContent,
          source: value.data.source,
          reviewerName: value.data.editorName,
          imgUrl: ''
        };
        setDaysDtl(data);
      }
    });
  }, []);

  return (
    <View className={css.home}>
      <Header message='主题党日详情' left='140px' />
      <Return />
      <View className={css.content}>
        <ThemeDtl info={daysDtl} />
      </View>
    </View>
  );
}